home *** CD-ROM | disk | FTP | other *** search
Text File | 1999-06-19 | 2.7 KB | 95 lines | [TEXT/CWIE] |
- // EvenMoreFiles.c
- // Copyright © 1999 Polaschek Computing, Inc. All rights reserved.
- //
- // Insert comment here
- //
-
- #include "EvenMoreFiles.h"
-
- /*#ifdef __cplusplus
- #error "The C++ compiler should not be active"
- #endif*/
-
- OSErr FSpGetFXInfo(const FSSpec* spec, FXInfo* xInfo)
- {
- CInfoPBRec infoRec = {0};
- OSErr err = noErr;
-
- infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name; // cast away constness
- infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
- infoRec.hFileInfo.ioDirID = spec->parID;
- err = PBGetCatInfoSync(&infoRec);
- if (err == noErr) {
- *xInfo = infoRec.hFileInfo.ioFlXFndrInfo;
- }
-
- return err;
- }
-
-
- OSErr FSpSetFXInfo(const FSSpec* spec, FXInfo* xInfo)
- {
- CInfoPBRec infoRec = {0};
- OSErr err = noErr;
-
- infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name;
- infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
- infoRec.hFileInfo.ioDirID = spec->parID;
- err = PBGetCatInfoSync(&infoRec);
- if (err == noErr) {
- // we have to restore ioDirID, since PBGetCatInfo changes it,
- // and if I don't restore it, I try looking for the directory
- // that has the id of the file index of the file, which isn't
- // found, which causes a fnfErr. Sheesh.
- infoRec.hFileInfo.ioDirID = spec->parID;
- infoRec.hFileInfo.ioFlXFndrInfo = *xInfo;
- err = PBSetCatInfoSync(&infoRec);
- }
-
- return err;
- }
-
-
- OSErr FSpGetExtendedFileInfo(const FSSpec* spec, ExtendedFileInfo* xInfo)
- {
- CInfoPBRec infoRec = {0};
- OSErr err = noErr;
-
- infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name; // cast away constness
- infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
- infoRec.hFileInfo.ioDirID = spec->parID;
- err = PBGetCatInfoSync(&infoRec);
- if (err == noErr) {
- // I can't just copy. The structures are binary-compatible though
- // (it says so in Finder.h), so I can just BlockMove the data over.
- BlockMoveData(&infoRec.hFileInfo.ioFlXFndrInfo, xInfo, sizeof(ExtendedFileInfo));
- }
-
- return err;
- }
-
-
- OSErr FSpSetExtendedFileInfo(const FSSpec* spec, ExtendedFileInfo* xInfo)
- {
- CInfoPBRec infoRec = {0};
- OSErr err = noErr;
-
- infoRec.hFileInfo.ioNamePtr = (unsigned char *)spec->name;
- infoRec.hFileInfo.ioVRefNum = spec->vRefNum;
- infoRec.hFileInfo.ioDirID = spec->parID;
- err = PBGetCatInfoSync(&infoRec);
- if (err == noErr) {
- // I can't just copy. The structures are binary-compatible though
- // (it says so in Finder.h), so I can just BlockMove the data over.
- BlockMoveData(xInfo, &infoRec.hFileInfo.ioFlXFndrInfo, sizeof(ExtendedFileInfo));
- // we have to restore ioDirID, since PBGetCatInfo changes it,
- // and if I don't restore it, I try looking for the directory
- // that has the id of the file index of the file, which isn't
- // found, which causes a fnfErr. Sheesh.
- infoRec.hFileInfo.ioDirID = spec->parID;
- err = PBSetCatInfoSync(&infoRec);
- }
-
- return err;
- }
-